package ca.usherbrooke.domus.sipnmove.call.impl;

import java.util.Map;

import ca.usherbrooke.domus.sipnmove.call.Call;
import ca.usherbrooke.domus.sipnmove.call.CallFactory;
import ca.usherbrooke.domus.sipnmove.sip.SipFacade;

/**
 * Factory of SIP call
 */
public class SipCallFactory implements CallFactory {

	/**
	 * SIP facade
	 */
	private SipFacade sipFacade;
	
	@Override
	public Call createCall(Map<String, Object> callInformation) {
		
		String callId = sipFacade.generateCallId();
		
		SocketCall socketCall;
		if((Boolean) callInformation.get("initiated") == true)
		{
			socketCall = new SocketCall(true);
		}
		else
		{
			socketCall = new SocketCall(false);
		}
		
		SipCall sipCall = new SipCall(callId);
		sipCall.setDecoratedCall((Call) socketCall);
		sipCall.setSipFacade(sipFacade);
		
		return (Call) sipCall;
	}
	

	/**
	 * @return the sipFacade
	 */
	public SipFacade getSipFacade() {
		return sipFacade;
	}


	/**
	 * @param sipFacade the sipFacade to set
	 */
	public void setSipFacade(SipFacade sipFacade) {
		this.sipFacade = sipFacade;
	}

}
